package com.ruoyi.locate.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.locate.domain.WWarehouseMapScale;
import com.ruoyi.locate.service.IWWarehouseMapScaleService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 仓位标尺Controller
 * 
 * @author ruoyi
 * @date 2025-01-06 13:13:08
 */
@RestController
@RequestMapping("/locates/scale")
public class WWarehouseMapScaleController extends BaseController
{
    @Autowired
    private IWWarehouseMapScaleService wWarehouseMapScaleService;

    /**
     * 查询仓位标尺列表
     */
    @PreAuthorize("@ss.hasPermi('locates:scale:list')")
    @GetMapping("/list")
    public TableDataInfo list(WWarehouseMapScale wWarehouseMapScale)
    {
        startPage();
        List<WWarehouseMapScale> list = wWarehouseMapScaleService.selectWWarehouseMapScaleList(wWarehouseMapScale);
        return getDataTable(list);
    }

    /**
     * 导出仓位标尺列表
     */
    @PreAuthorize("@ss.hasPermi('locates:scale:export')")
    @Log(title = "仓位标尺", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WWarehouseMapScale wWarehouseMapScale)
    {
        List<WWarehouseMapScale> list = wWarehouseMapScaleService.selectWWarehouseMapScaleList(wWarehouseMapScale);
        ExcelUtil<WWarehouseMapScale> util = new ExcelUtil<WWarehouseMapScale>(WWarehouseMapScale.class);
        util.exportExcel(response, list, "仓位标尺数据");
    }

    /**
     * 获取仓位标尺详细信息
     */
    @PreAuthorize("@ss.hasPermi('locates:scale:query')")
    @GetMapping(value = "/{scaleId}")
    public AjaxResult getInfo(@PathVariable("scaleId") Long scaleId)
    {
        return success(wWarehouseMapScaleService.selectWWarehouseMapScaleByScaleId(scaleId));
    }

    /**
     * 新增仓位标尺
     */
    @PreAuthorize("@ss.hasPermi('locates:scale:add')")
    @Log(title = "仓位标尺", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WWarehouseMapScale wWarehouseMapScale)
    {
        wWarehouseMapScale.setCreateBy(getNickName());
        return toAjax(wWarehouseMapScaleService.insertWWarehouseMapScale(wWarehouseMapScale));
    }

    /**
     * 修改仓位标尺
     */
    @PreAuthorize("@ss.hasPermi('locates:scale:edit')")
    @Log(title = "仓位标尺", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WWarehouseMapScale wWarehouseMapScale)
    {
        wWarehouseMapScale.setUpdateBy(getNickName());
        return toAjax(wWarehouseMapScaleService.updateWWarehouseMapScale(wWarehouseMapScale));
    }

    /**
     * 删除仓位标尺
     */
    @PreAuthorize("@ss.hasPermi('locates:scale:remove')")
    @Log(title = "仓位标尺", businessType = BusinessType.DELETE)
	@DeleteMapping("/{scaleIds}")
    public AjaxResult remove(@PathVariable Long[] scaleIds)
    {
        return toAjax(wWarehouseMapScaleService.deleteWWarehouseMapScaleByScaleIds(scaleIds));
    }

    /**
     * 获取仓位标尺详细信息
     */
    //@PreAuthorize("@ss.hasPermi('locates:scale:query')")
    @GetMapping(value = "/data/{parentId}")
    public AjaxResult getMapScale(@PathVariable("parentId") Long parentId)
    {
        return success(wWarehouseMapScaleService.selectWWarehouseMapScaleByparentId(parentId));
    }
}
